package com.vanguard.p2p.business.service.impl;

import com.vanguard.p2p.base.vo.UserVO;
import com.vanguard.p2p.business.domain.Member;
import com.vanguard.p2p.business.domain.MemberLoginLog;
import com.vanguard.p2p.business.example.MemberExample;
import com.vanguard.p2p.business.mapper.MemberMapper;
import com.vanguard.p2p.business.service.IUserService;
import com.vanguard.p2p.constant.CommonReturnCode;
import com.vanguard.p2p.exception.ValidateException;
import com.vanguard.p2p.pojo.P2PResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author vanguard
 * @version 1.0
 * @describe
 * @date 2018/02/12
 */
@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private MemberMapper memberMapper;

    @Override
    public Integer insertUser(Member member) throws ValidateException {
       //验证手机号唯一性
        MemberExample memberExample = new MemberExample();
        memberExample.createCriteria().andPhoneNumberEqualTo(member.getPhoneNumber());
        List<Member> memberList = memberMapper.selectByExample(memberExample);
        if(null != memberList && memberList.size() > 0) {
            throw new ValidateException(CommonReturnCode.BAD_REQUEST.getCode(), "该手机号已被注册，请登录！");
        }


        return null;
    }

    @Override
    public Member getByLoginName(String loginName) {
        return null;
    }

    @Override
    public Boolean getByUsername(String userName) { return null; }

    @Override
    public Member getByEmail(String email) {
        return null;
    }

    @Override
    public UserVO getById(Long userId) {
        return null;
    }

    @Override
    public Integer updateLogById(Long memId, MemberLoginLog memberLoginLog) {
        return null;
    }

    @Override
    public P2PResult updateEmailActive(String email) {
        return null;
    }

    @Override
    public Integer getEmailIsActive(Long userId) {
        return null;
    }

    @Override
    public P2PResult updatePerfectUser(String email, String telephone, String realName) throws ValidateException {
        return null;
    }

    @Override
    public P2PResult updatePasswordByEmail(String loginPassword, String email) {
        return null;
    }
}
